package com.leo.oplayer.view;


import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.leo.oplayer.R;
import com.leo.oplayer.adapter.MonthStatAdapter;
import com.leo.oplayer.dao.DBService;
import com.leo.oplayer.model.MonthStat;
import com.leo.oplayer.service.ContactService;

public class RankView extends Activity implements OnItemClickListener {
	
	private static final String TAG = "RankView";

	private ContactService service;
	
	private ListView mylist;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.adapter_list);
		service = new ContactService(new DBService(this));
		
		//获取总列表，及总列表中point最小值
		List<MonthStat> list = service.getDbService().searchTotalList();		
		Integer min = service.getDbService().getTotalMin();		
		Log.d("RankView", "min:"+min);
		
		ArrayAdapter<MonthStat> adapter = new MonthStatAdapter(this,R.layout.month_stat,list,min);
		
		mylist = (ListView) findViewById(R.id.ListView01);
		mylist.setAdapter(adapter);
		mylist.setOnItemClickListener(this);
		
	}

	public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
		Log.d("onItemClick", "position:"+position);
		
		Log.i(TAG, "listener in");
		TextView phoneId = (TextView)v.findViewById(R.id.phoneId);
		Toast.makeText(v.getContext(), "hehe", Toast.LENGTH_LONG).show();
		Log.i(TAG, String.valueOf(phoneId.getText()));	
	}
}
